<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ include file="/common/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'restlist.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	
	<script type="text/javascript">
	function initall(){
	var address = "${ sessionScope.address}";
	var company = "${ sessionScope.company}";
	var drink = "${ sessionScope.drink}";
		if(address!=""){
			initaddress(address);
		}
		if(company != ""){
			initcompany(company);//alert("初始化公司！");
		}
		if(drink !=""){
			initdrink(drink);
		}
	}
	function initaddress(val){
		var ops = document.getElementById("addr").options;
		for(var i=0; i<ops.length; i++){
			if(ops[i].value==val){
				ops[i].selected=true;
			}else{
				ops[i].selected=false;
			}
		}
	}
	
	function initdrink(val){
		var ops = document.getElementsByName("dri");//ById("addr").options;
		for(var i=0; i<ops.length; i++){
			if(ops[i].value==val){
				ops[i].checked=true;
			}else{
				ops[i].checked=false;
			}
		}
	}
	function initcompany(val){
		var ops = document.getElementsByName("com");//ById("addr").options;
		for(var i=0; i<ops.length; i++){
			if(ops[i].value==val){
				ops[i].checked=true;
			}else{
				ops[i].checked=false;
			}
		}
	}
	</script>
</head>

<body onload="javascript:initall()">


<!-- <script type="text/javascript"> 
if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){
    if(window.location.href.indexOf("?mobile")<0){
        try{
            if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){
                window.location.href="http://www.baidu.com";
            }else if(/iPad/i.test(navigator.userAgent)){
            window.location.href="http://www.google.com";
            }else{
                window.location.href="http://www.google.com";
            }
        }catch(e){}
    }
}
</script>
 -->
 
 <script type="text/javascript">
    var browser = {
        versions : function() {
            var u = navigator.userAgent, app = navigator.appVersion;
            return {//移动终端浏览器版本信息                                 
            trident : u.indexOf('Trident') > -1, //IE内核                                 
            presto : u.indexOf('Presto') > -1, //opera内核                                 
            webKit : u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核                                 
            gecko : u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核                                
            mobile : !!u.match(/AppleWebKit.*Mobile.*/)
                    || !!u.match(/AppleWebKit/), //是否为移动终端                                 
            ios : !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端                 
            android : u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器                                 
            iPhone : u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器                    
            iPad: u.indexOf('iPad') > -1, //是否iPad       
            webApp : u.indexOf('Safari') == -1,//是否web应该程序，没有头部与底部
            google:u.indexOf('Chrome')>-1
        };
    }(),
    language : (navigator.browserLanguage || navigator.language).toLowerCase()
    }
   
  // alert(navigator.userAgent);
  /*   if(browser.versions.mobile){
    	alert("语言版本: "+browser.language);
    	window.location.href="http://www.baidu.com";
    }else{
    	window.location.href="http://www.google.com";
    	alert(" 是否为移动终端: "+browser.versions.mobile);
    } */
    
    function address(va){
    document.getElementById("address").value=va;
    document.getElementById("drink").value="${ sessionScope.drink}";
    document.getElementById("company").value="${ sessionScope.company}";
    document.getElementById("form1").submit();
    }
    function company(id){
    document.getElementById("address").value="${ sessionScope.address}";
    document.getElementById("drink").value="${ sessionScope.drink}";
    if(document.getElementById(id).checked){
    	document.getElementById("company").value=document.getElementById(id).value;
    }else{
    	document.getElementById("company").value="";
    }
   
    document.getElementById("form1").submit();
    }
    function drink(id){
    document.getElementById("address").value="${ sessionScope.address}";
    if(document.getElementById(id).checked){
    	document.getElementById("drink").value=document.getElementById(id).value;
    }else{
		document.getElementById("drink").value="";
    }
    document.getElementById("company").value="${ sessionScope.company}";
    document.getElementById("form1").submit();
    }
</script>
<!--  360浏览器出现JS兼容性问题 JS判断为移动端浏览器需要后续解决 -->

	<form action="<%=path%>/restaurant/allrest.htm" method="post" id="form1">
		<input type="hidden" name="address" id="address">
		<input type="hidden" name="drink" id="drink">
		<input type="hidden" name="company" id="company">
	</form>

	所在地点：吉林省长春市吉林大学	<select onchange="address(this.options[this.selectedIndex].value)" id="addr">
								<option selected="selected" value="">请选择</option> 
								<option value="南苑" name="option">南苑</option>
								<option value="文苑" name="option">文苑</option>
								<option value="基础园" name="option" id="qq">基础园</option>
								<option value="经信" name="option">经信</option>
								<option value="图书馆" name="option">图书馆</option>
								<option value="三教" name="option">三教</option>
							</select><br>
							
							
	外卖商家：
	<input name="com" type="checkbox" value="全部" id="all" checked="checked" onchange="company(this.id)"><label for="all">全部</label>
	<input name="com" type="checkbox" value="饿了么" id="elem"  onchange="company(this.id)"><label for="elem">饿了么</label>
	<input name="com" type="checkbox" value="美团" id="meituan" onchange="company(this.id)"><label for="meituan">美团</label><br>
	
	
	饮料：<input name="dri" type="checkbox" value="可口可乐" id="cocacola" onclick="drink(this.id)"><label for="cocacola">可口可乐</label>
	<input name="dri" type="checkbox" value="冰糖雪梨" id="bingtang" onchange="drink(this.id)"><label for="bingtang">冰糖雪梨</label>

	<br><br><br>
	<c:forEach items="${list}" var="rest">
	<div>
		餐厅名：${rest.mName}<br>
  		配送时间:${rest.mSendTime}<br>
  		<a href="http://waimai.meituan.com/${rest.mHrefUrl}">去买</a><br>
  		起送价:<c:choose>
				<c:when test="${empty rest.mSendPrice}">
				免费配送
				</c:when>
				<c:otherwise>
				${rest.mSendPrice}
				</c:otherwise>
			</c:choose><br>
		满减列表：${rest.mSaleList}<br>
		来自：<c:if test="${rest.mCompany==0}">美团</c:if><c:if test="${rest.mCompany==1}">饿了么</c:if><br>
		图片：<img src="${rest.mImgUrl}" /><br>
		<br>
		</div>
	</c:forEach>
</body>
</html>
